import axios from '../../request'
export default {
    namespaced: true,
    state: {
        value: '',
        list:[
            {img:require("../../assets/home-images/备份.png")},
            {img:require("../../assets/home-images/备份 2.png")},
            { img: require("../../assets/home-images/备份 7.png") },
            {img:require("../../assets/home-images/备份 6.png")},
            { img: require("../../assets/home-images/备份 3.png") },
            {img:require("../../assets/home-images/(1).png")},
            {img:require("../../assets/home-images/备份 5.png")},
        ],
        list2: [
            {img:require("../../assets/home-images/备份 10.png")},
            {img: require("../../assets/home-images/备份 8.png") },
            {img:require("../../assets/home-images/画板(1).png")},
            {img:require("../../assets/home-images/备份 9.png")},
        ],
        list3:[
            {img:require("../../assets/home-images/保洁1.png")},
            {img:require("../../assets/home-images/保洁2.png")},
            {img:require("../../assets/home-images/保洁3.png")},
        ],
        nameList: [],
        nowList: [],
        cleanList:[]
    },
    mutations: {
        INIT_LIST(state, { data }) {
            state.nameList=data.data.data
        },
        SEARCH_LIST(state, { data }) {
            state.nowList = data.data.data;
            state.nowList.length = 4;
            console.log(state.nowList);
        },
        SEARCH_LIST2(state, { data }) {
            state.cleanList = data.data.data;
            state.cleanList.length = 3;
            console.log(state.cleanList);
        }
    },
    actions: {
        init({commit}) {
            let API="/api/sys/serviceType"
            axios.get(API).then(data => {
                commit("INIT_LIST", {
                    data
                })
            });
            let API2 = "/api/sys/myService"
            axios.get(API2, { params: { id: 2 } }).then(data => {
                commit("SEARCH_LIST", {
                    data
                })
            });
            axios.get("/api/sys/myService",{params:{id:1}}).then(data=>{
                commit("SEARCH_LIST2",{
                    data
                })
            })
        }
    }
}